
<template>
    <div>
        <!-- 查询搜索按钮 -->
        <el-row>
            <el-col :span="23" class="" id="serachId">
            <el-form :inline="true" :model="filters">
            <el-form-item style="float:right">
                <el-button type="primary" v-on:click="getList" size="small">查询</el-button>
            </el-form-item>
            <el-form-item style="float:right">
                <el-input v-model="filters.appName" placeholder="请输入应用名称" size="small" @keyup.enter.native="searchEnterFun"></el-input>
            </el-form-item>
            </el-form>
            </el-col>
        </el-row>  

        <!-- 列表展示 -->
        <el-row class="tac toolbar ">
            <el-col :span="23" class="titleLineSymbolTwo" >
                <el-table :data="tableData" style="width: 100%"  v-loading="listLoading" class="bgColorf3f7fc" >
                    <el-table-column type="index" label="序号"  width="50">
                    </el-table-column>
                    <el-table-column prop="appName"  label="应用名称">
                    </el-table-column>
                    <el-table-column prop="applicationType.className" label="应用分类">
                    </el-table-column>
                    <el-table-column prop="publishFlag" label="状态" :formatter="formatPublishFlag">
                    </el-table-column>
                    <el-table-column prop="marketNames" label="应用市场" min-width="140">
                    </el-table-column>
                    <el-table-column prop="createDate" label="创建时间" min-width="120" :formatter="formatCreateDate">
                    </el-table-column>
                    <el-table-column fixed="right" label="操作" width="150">
                        <template slot-scope="scope">
                            <el-button @click="handleClickDetail(scope.$index,scope.row)" type="text" size="small">详情</el-button>
                            <el-button @click="handleClickModify" type="text" size="small">修改</el-button>
                            <el-button @click="versionEditSecond(scope.$index, scope.row)" type="text" size="small">版本信息</el-button><br />
                            <div class="titleDetailLeft">
                                <el-button  v-if="scope.row.publishFlag === 1" type="text" size="small" @click="toPublishApp(scope.$index, scope.row)">发布应用</el-button><!-- 发布了其中一种版本之后，还可以发布其它版本 -->
                                <el-button  v-else type="text" size="small" @click="underReview">审核中</el-button>
                                <el-button @click="deleteAllAppInfo(scope.row)" type="text" size="small">删除</el-button>
                            </div>
                        </template>
                    </el-table-column>
                </el-table>
            </el-col>
            <el-col :span="23" class="marginTop10px">
            <el-pagination layout="total, prev, pager, next, jumper" @current-change="handleCurrentPageChange"
                    :current-page="pageNum" :page-size="pageSize" :total="total">
            </el-pagination>
            </el-col>
        </el-row>

        <!-- 组件发布应用-->
        <el-dialog title="发布应用" :visible.sync="publishAppPageVisible" :modal-append-to-body="false" @close='closePublishAppPageDialog'>
            <publish-app-sub-page v-if="publishAppSubPageVisible" @goToSelect="baseAddHiden" :toPublishAppData="toPublishAppData"></publish-app-sub-page>
            <publish-app-select-market-sub-page v-if="isShowSelectMarket" @backToBase='baseAddShow' :toPublishAppData="toPublishAppData"></publish-app-select-market-sub-page><!--@goToSuccess='selectMarketHiden'-->
        </el-dialog>

        <!-- 组件详情 -->
        <el-dialog :title="apptitle" :visible.sync="appDetailVisible" :modal-append-to-body="false">
            <application-management-base-detail
                    :appDetailInfo="appDetailInfo">
            </application-management-base-detail>
        </el-dialog>

        <!-- 版本信息 -->
        <el-dialog title="版本信息 [巡逻签到]" :visible.sync="versionDialogSecond" :modal-append-to-body="false">
            <version-information></version-information>
        </el-dialog>
    </div>
</template>

<script>
    import util from '@/views/api/utils.js';
    import authorize from './components/app-authorize.vue';
    import versionInformation from './components/versionInformation.vue';
    import publishAppSubPage from './publishAppSubPage.vue';// 发布页面
    import applicationManagementBaseDetail from './components/applicationManagementBaseDetail.vue';// 详情页面
    import PublishAppSelectMarketSubPage from "./publishAppSelectMarketSubPage";
    import {doAuthDept,
            getAppList_new,
            getExtendList,
            getApiList,
            versionList,
            getMarketList,
            editApi,
            getApplicationTypeList,
            updateVersion,
            createApi,
            createVersion,
            addApp,
            editApp,
            deleteApi,
            publishMarket,
            addPublishMarket,
            removeMarket,
            getpublishMarketList,
            sendObj,
            getAllPublishMarket,
            getOrganizationList,
            getAuth,
            addAuth,
            delAuth,
            getSupplierList,
            searchApimanageService,
            deleteAllAppInfo} from '../../api/api';

    export default {
        // 组件注册
        components: {
            PublishAppSelectMarketSubPage,
            publishAppSubPage,
            authorize,
            versionInformation,
            publishAppSubPage,// 发布页面
            applicationManagementBaseDetail,
        },
        // props: {toPublishAppData: ""},
        data() {
            return {
                apptitle: '应用名称：',
                rowAppObj: '',
                text: '',
                filters: {
                    appCode: '',
                    appName: '',
                    marketName: ''
                },
                tableData: [{applicationType: {},}],
                publishMarketList: [],
                apiTableList: [],
                deptTableData: [],
                total: 0,
                pageNum: 1,
                pageSize: 5,
                apiTotal: 0,
                apiPageNum: 1,
                apiPageSize: 2,
                webTotal: 0,
                webPageNum: 1,
                webPageSize: 2,
                iosTotal: 0,
                iosPageNum: 1,
                iosPageSize: 2,
                androidTotal: 0,
                androidPageNum: 1,
                androidPageSize: 2,
                deptTotal: 0,
                deptPageNum: 1,
                deptPageSize: 5,
                marketTotal: 0,
                marketPageNum: 1,
                marketPageSize: 2,
                listLoading: true,
                apiListLoading: false,
                webListLoading: false,
                publishLoading: false,
                market: [],
                clazz: [],
                webConfirmDialogVisible: false,//web信息确认弹框
                iosConfirmDialogVisible: false,
                androidConfirmDialogVisible: false,
                webDetailDialogVisible: false,
                iosDetailDialogVisible: false,
                androidDetailDialogVisible: false,
                choiceVersionDialogVisible: false,//选择终端版本
                publishAppDialogVisible: false,//发布
                publishPositionDialogVisible: false,
                deptListLoading: false,
                allPublishMarketList: [],
                apiTab: {
                    appCode: '',
                    apiName: '',
                    apiAddrss: '',
                    gatewayAddrss: ''
                },
                versionTab: {
                    appCode: '',
                },
                webForm: {
                    appCode: '',
                    version: '',
                    defaultPackage: 1,
                    isRelyOnColud: 0,
                    winType: '',
                    urlNum: '',
                    accessUrl: '',
                    versionType: '',
                    remark: ''
                },
                webDetailForm: {
                    appCode: '',
                    version: '',
                    defaultPackage: '',
                    isRelyOnColud: '',
                    winType: '',
                    urlNum: '',
                    accessUrl: '',
                    versionType: '',
                    remark: ''
                },
                webFormRules: {
                    version: [
                        {required: true, message: '请输入版本号', trigger: 'blur'}
                    ],
                    gatewayAddrss: [
                        {required: true, message: '请输入网关地址', trigger: 'blur'}
                    ],
                },
                webConfirmForm: {
                    appCode: '',
                    appName: '',
                    appMarket: '',
                    appType: '',
                    version: '',
                    defaultPackage: '',
                    winType: '',
                    remark: ''
                },
                iosForm: {
                    version: '',
                    compile: '',
                    forceUpdate: '',
                    isDefaultInstall: '',
                    validateType: '',
                    frameType: '',
                    forceUpdate: '',
                    installPackageUrl: '',
                    accessUrl: '',
                    startupConfig: '',
                    extendConfig: '',
                    remark: ''
                },
                iosDetailForm: {
                    version: '',
                    compile: '',
                    forceUpdate: '',
                    isDefaultInstall: '',
                    validateType: '',
                    frameType: '',
                    forceUpdate: '',
                    installPackageUrl: '',
                    accessUrl: '',
                    startupConfig: '',
                    extendConfig: '',
                    remark: ''
                },
                iosConfirmForm: {
                    appCode: '',
                    appName: '',
                    appMarket: '',
                    appType: '',
                    version: '',
                    defaultPackage: '',
                    winType: '',
                    remark: ''
                },
                androidDetailForm: {
                    version: '',
                    compile: '',
                    forceUpdate: '',
                    isDefaultInstall: '',
                    validateType: '',
                    frameType: '',
                    forceUpdate: '',
                    installPackageUrl: '',
                    accessUrl: '',
                    startupConfig: '',
                    extendConfig: '',
                    remark: ''
                },
                androidConfirmForm: {
                    appCode: '',
                    appName: '',
                    appMarket: '',
                    appType: '',
                    version: '',
                    defaultPackage: '',
                    winType: '',
                    remark: ''
                },
                appTermianl: [],//适用终端 绑定对象
                appPublishFrom: {
                    appCode: '',
                    appName: '',

                },
                Web: [],
                IOS: [],
                Android: [],
                publishWebInfoFrom: {
                    accessUrl: '',
                    appBaseInfo: '',
                    appCode: '',
                    appMarket: '',
                    appName: '',
                    appType: '',
                    compile: '',
                    creater: '',
                    currentVersion: '',
                    defaultPackage: '',
                    extendConfig: '',
                    forceUpdate: '',
                    frameType: '',
                    id: '',
                    installPackage: '',
                    installPackageSize: '',
                    installPackageUrl: '',
                    isDefaultInstall: '',
                    isRelyOnColud: '',
                    logoImage: '',
                    publish: '',
                    remark: '',
                    startupConfig: '',
                    urlNum: '',
                    validateType: '',
                    version: '',
                    versionType: '',
                    winType: ''

                },
                publishIOSInfoFrom: {
                    accessUrl: '',
                    appBaseInfo: '',
                    appCode: '',
                    appMarket: '',
                    appName: '',
                    appType: '',
                    compile: '',
                    creater: '',
                    currentVersion: '',
                    defaultPackage: '',
                    extendConfig: '',
                    forceUpdate: '',
                    frameType: '',
                    id: '',
                    installPackage: '',
                    installPackageSize: '',
                    installPackageUrl: '',
                    isDefaultInstall: '',
                    isRelyOnColud: '',
                    logoImage: '',
                    publish: '',
                    remark: '',
                    startupConfig: '',
                    urlNum: '',
                    validateType: '',
                    version: '',
                    versionType: '',
                    winType: ''

                },
                publishAndroidInfoFrom: {
                    accessUrl: '',
                    appBaseInfo: '',
                    appCode: '',
                    appMarket: '',
                    appName: '',
                    appType: '',
                    compile: '',
                    creater: '',
                    currentVersion: '',
                    defaultPackage: '',
                    extendConfig: '',
                    forceUpdate: '',
                    frameType: '',
                    id: '',
                    installPackage: '',
                    installPackageSize: '',
                    installPackageUrl: '',
                    isDefaultInstall: '',
                    isRelyOnColud: '',
                    logoImage: '',
                    publish: '',
                    remark: '',
                    startupConfig: '',
                    urlNum: '',
                    validateType: '',
                    version: '',
                    versionType: '',
                    winType: ''

                },
                addPublishMarketForm: {
                    marketCode: '',
                    applictionType: ''
                },
                addPublishMarketFormRules: {
                    marketCode: [
                        {required: true, message: '请输入应用市场', trigger: 'blur'}
                    ],
                    applictionType: [
                        {required: true, message: '请选择应用分类', trigger: 'blur'}
                    ],
                },
                defaultProps: {
                    label: 'marketName',
                    isLeaf: 'leaf',
                },
                paramData: {sys: 1, module: 1, keyId: "12312312312"},// todo 文件上传附加参数，必须先定义，而且后续修改必须用：属性引用修改：this.paramData.keyId="9999999999999999999999";
                uploadUrl: '',
                //---------------------------------------------------medoingnow.
                versionDialogSecond: false,
                appDetailVisible: false,
                publishAppPageVisible:false,
                publishAppSubPageVisible: false,// 控制是否显示发布页面
                isShowSelectMarket:false,// 控制是否显示发布app的选择市场页面
                toPublishAppData: {
                    toPublishAppObj: {},
                    developerList: {},
                    applicationTypeList: {},
                    appClassificationList: {}
                },// 发布app 对象传输：带发布app，开发者列表，应用类型列表，应用类别列表(应用所在区域)
                appDetailInfo: "",

            };
        },
        methods: {
            //实现回车键搜索功能
			searchEnterFun:function(e){
				this.getList();
            },
            getList() {
                let params = {
                    pageNum: this.pageNum,
                    pageSize: this.pageSize,
                    appCode: this.filters.appCode,
                    appName: this.filters.appName,
                    marketName: this.filters.marketName,
                    // marketNameList:this.$refs.tree.getCheckedKeys(),
                };
                console.log(params);
                this.listLoading = true;
                //NProgress.start();
                getAppList_new(params).then(function (result) {
                    this.tableData = result.data.list;
                    console.log(this.tableData)
                    this.pageNum = result.data.pageNum;
                    this.pageSize = result.data.pageSize;
                    this.total = result.data.total;
                    this.listLoading = false;
                }.bind(this)).catch(function (error) {
                    this.listLoading = false;
                    console.log(error);
                }.bind(this));
            },
            topublishMarketList() {//发布市场列表 确认页
                let params = {
                    appCode: this.appPublishFrom.appCode,
                };
                getAllPublishMarket(params).then(function (result) {
                    this.allPublishMarketList = result.data;
                }.bind(this)).catch(function (error) {
                    console.log(error);
                }.bind(this));
            },
         
            //获取api列表
            apiList() {
                let params = {
                    pageNum: this.apiPageNum,
                    pageSize: this.apiPageSize,
                    appCode: this.apiTab.appCode

                };
                this.apiListLoading = true;
                getApiList(params).then(function (result) {
                    this.apiTableList = result.data.list;
                    this.apiPageNum = result.data.pageNum;
                    this.apiPageSize = result.data.pageSize;
                    this.apiTotal = result.data.total;
                    this.apiListLoading = false;
                }.bind(this)).catch(function (error) {
                    this.apiListLoading = false;
                    console.log(error);
                }.bind(this));
            },
            toPublish: function (para) {//发布版本
                this.$confirm('确认发布吗？', '提示', {}).then(() => {
                    this.publishLoading = true;
                    //NProgress.start();
                    let form;
                    if (para == 1) {
                        form = Object.assign({}, this.webConfirmForm);
                    } else if (para == 2) {
                        form = Object.assign({}, this.iosConfirmForm);
                    } else {
                        form = Object.assign({}, this.androidConfirmForm);

                    }
                    let params = {
                        publish: 1,
                        id: form.id,
                        appCode: form.appCode,
                        versionType: form.versionType
                    }
                    console.log(params)
                    updateVersion(params).then((res) => {
                        this.publishLoading = false;
                        this.$message({
                            message: '发布成功',
                            type: 'success'
                        });
                        if (para == 1) {
                            this.webConfirmDialogVisible = false;
                            this.webForm = false;
                            this.webList();
                        } else if (para == 2) {
                            this.iosConfirmDialogVisible = false;
                            this.iosList();
                        } else {
                            this.androidConfirmDialogVisible = false;
                            this.androidList();
                        }
                    });
                });
            },
            doPublish: function () {//发布应用
                let data1 = Object.assign({}, this.appPublishFrom);
                let data2 = Object.assign({}, this.publishWebInfoFrom);
                let data3 = Object.assign({}, this.publishIOSInfoFrom);
                let data4 = Object.assign({}, this.publishAndroidInfoFrom);
                let data5 = this.allPublishMarketList;//确认发布 市场  list
                let params = {
                    app: data1,
                    marketList: data5
                }
                if (data2.id != '') {
                    params['ver1'] = data2;
                }
                if (data3.id != '') {
                    params['ver2'] = data3;
                }
                if (data4.id != '') {
                    params['ver3'] = data4;
                }
                console.log(params);
                this.$confirm('确认发布吗？', '提示', {}).then(() => {
                    sendObj(params).then((res) => {
                        this.$message({
                            message: '发布成功',
                            type: 'success'
                        });
                        this.choiceVersionDialogVisible = false;
                        this.publishAppDialogVisible = false;
                        this.getList();
                    });
                });
            },
            putDown(index, row) {
                //直接下架
                let _this = this;
                let type;
                let typeInt
                if (row.versionType == 1) {
                    type = ' Web ',
                        typeInt = 1
                } else if (row.versionType == 2) {
                    type = ' IOS ',
                        typeInt = 2
                } else {
                    type = ' Android ',
                        typeInt = 3
                }
                this.$confirm('确认下架' + type + row.version + ' 当前版本？', '提示', {}).then(() => {
                    if (typeInt == 1) {
                        this.webListLoading = true;
                    }
                    let data = Object.assign({}, row);
                    let params = {
                        id: data.id,
                        currentVersion: 0,
                    }
                    updateVersion(params).then((res) => {
                        if (typeInt == 1) {
                            this.webListLoading = false;
                        }
                        this.$message({
                            message: '下架成功',
                            type: 'success'
                        });
                        if (typeInt == 1) {
                            _this.webList();
                        } else if (typeInt == 2) {
                            _this.iosList();
                        } else {
                            _this.androidList();
                        }
                    });
                });
            },
            check(index, row) {
                //查询当前应用是否已有版本上架
                let data = Object.assign({}, row);
                let params = {
                    appCode: data.appCode,
                    versionType: data.versionType,
                    currentVersion: 1,
                }
                versionList(params).then((res) => {
                    let size = res.data.list.length;
                    if (size == 0) {
                        this.isPublishVersion(index, row)
                    } else {
                        this.$alert('请先下架当前版本'), {
                            confirmButtonText: '确定',
                        }
                    }
                });
            },
            isPublishVersion(index, row) {//版本是否已发布
                let data = Object.assign({}, row);
                if (data.publish == 1) {
                    this.putUP(index, row);
                } else {
                    this.$alert('该版本未发布'), {
                        confirmButtonText: '确定',
                    }
                }
            },
            publish_webList() {//获取有效web版本
                if (this.versionTab.appCode === "") {
                    return;
                }
                let params = {
                    version: '',
                    appCode: this.versionTab.appCode,
                    currentVersion: 1,
                    versionType: 1
                };
                console.log(this.Web + ">>>>>>>>>");
                versionList(params).then(function (result) {
                    this.Web = result.data.list;
                }.bind(this)).catch(function (error) {
                    console.log(error);
                }.bind(this));
            },
            publish_iosList() {
                let params = {
                    version: '',
                    appCode: this.versionTab.appCode,
                    currentVersion: 1,
                    versionType: 2
                };
                versionList(params).then(function (result) {
                    this.IOS = result.data.list;
                }.bind(this)).catch(function (error) {
                    console.log(error);
                }.bind(this));
            },
            publish_androidList() {//android 版本下拉框
                let params = {
                    version: '',
                    appCode: this.versionTab.appCode,
                    currentVersion: 1,
                    versionType: 3
                };
                versionList(params).then(function (result) {
                    this.Android = result.data.list;
                }.bind(this)).catch(function (error) {
                    console.log(error);
                }.bind(this));
            },
            linkVersion: function (ele) {//查询版本关联信息
                let params = {id: ele}
                versionList(params).then(function (result) {
                    let type = result.data.list[0].versionType;
                    let data = result.data.list[0];

                    if (type == 1) {
                        this.publishWebInfoFrom = Object.assign({}, data);
                    } else if (type == 2) {
                        this.publishIOSInfoFrom = Object.assign({}, data);
                    } else {
                        this.publishAndroidInfoFrom = Object.assign({}, data);
                    }
                }.bind(this)).catch(function (error) {
                    console.log(error);
                }.bind(this));

            },
            publishConfirm: function () {//应用发布-》确认页面提交操作
                //保存初始发布
                let v1 = Object.assign({}, this.publishWebInfoFrom);
                let v2 = Object.assign({}, this.publishIOSInfoFrom);
                let v3 = Object.assign({}, this.publishAndroidInfoFrom);
                let vid1 = v1.id;
                let vid2 = v2.id;
                let vid3 = v3.id;
                if (vid1 == '' && vid2 == '' && vid3 == '') {
                    this.$message({
                        message: '请至少选择一个终端类型版本',
                        type: 'success'
                    });
                    return;
                }
                if (v1.id != 0) {//将该版本设置为初始发布版本
                    let params = {
                        id: v1.id,
                        isUseful: 1,
                    }
                    console.log(params);
                    updateVersion(params).then(function (result) {
                    }.bind(this)).catch(function (error) {
                        console.log(error);
                    }.bind(this));
                }
                if (v2.id != 0) {
                    let params = {
                        id: v2.id,
                        isUseful: 1,
                    }
                    console.log(params);
                    updateVersion(params).then(function (result) {

                    }.bind(this)).catch(function (error) {
                        console.log(error);
                    }.bind(this));
                }
                if (v3.id != 0) {
                    let params = {
                        id: v3.id,
                        isUseful: 1,
                    }
                    console.log(params);
                    updateVersion(params).then(function (result) {

                    }.bind(this)).catch(function (error) {
                        console.log(error);
                    }.bind(this));
                }
                this.topublishMarketList();

                this.publishAppDialogVisible = true;
            },
            deptList(obj) {
                let params = {
                    pageNum: this.deptPageNum,
                    pageSize: this.deptPageSize,
                    appCode: obj.appCode,
                }
                doAuthDept(params).then(function (result) {
                    let _this = this;
                    this.deptPageNum = result.data.data.pageNum;
                    this.deptPageSize = result.data.data.pageSize;
                    this.deptTotal = result.data.data.total;
                    _this.deptTableData = result.data.data.list;
                }.bind(this)).catch(function (error) {
                    this.deptListLoading = false;
                    console.log(error);
                }.bind(this));
            },
            Click(row) {
                let _this = this;
                console.log(row)
                if (row.isAuth) {
                    //to do 取消授权
                    this.$confirm('确认取消授权吗？', '提示', {}).then(() => {
                        delAuth(row).then(function (res) {
                            _this.deptListLoading = false;
                            _this.$message({
                                message: '成功',
                                type: 'success'
                            });
                            _this.deptList(_this.rowAppObj);
                        });
                    });
                } else {
                    // 授权
                    this.$confirm('确认授权吗？', '提示', {}).then(() => {
                        addAuth(row).then(function (res) {
                            _this.deptListLoading = false;
                            _this.$message({
                                message: '成功',
                                type: 'success'
                            });
                            _this.deptList(_this.rowAppObj);
                        });
                    });
                }
            },
            view: function (index, row) {
                if (row.versionType == 1) {
                    this.webDetailDialogVisible = true;
                    this.webDetailForm = Object.assign({}, row);
                    if (row.winType == 0) {//窗口类型回显
                        this.webDetailForm.winType = '最大化';
                    } else if (row.winType == 1) {
                        this.webDetailForm.winType = '横向布局';
                    } else {
                        this.webDetailForm.winType = '纵向布局';

                    }
                } else if (row.versionType == 2) {
                    this.iosDetailDialogVisible = true;
                    this.iosDetailForm = Object.assign({}, row);
                    if (row.validateType == 0) {
                        this.iosDetailForm.validateType = '单点登录验证';
                    } else {
                        this.iosDetailForm.validateType = '不验证';
                    }
                    if (row.frameType == 0) {
                        this.iosDetailForm.frameType = '原生开发';
                    } else if (row.frameType == 1) {
                        this.iosDetailForm.frameType = 'BingoTouch';
                    } else {
                        this.iosDetailForm.frameType = '标准WEB程序';
                    }
                } else {
                    this.androidDetailDialogVisible = true;
                    this.androidDetailForm = Object.assign({}, row);
                    if (row.validateType == 0) {
                        this.androidDetailForm.validateType = '单点登录验证';
                    } else {
                        this.androidDetailForm.validateType = '不验证';
                    }
                    if (row.frameType == 0) {
                        this.androidDetailForm.frameType = '原生开发';
                    } else if (row.frameType == 1) {
                        this.androidDetailForm.frameType = 'BingoTouch';
                    } else {
                        this.androidDetailForm.frameType = '标准WEB程序';
                    }
                }
            },
            // 如果新增web的时候没有发布版本 在这里发布
            publishVersion: function (index, row) {
                let params = {
                    appCode: row.appCode,
                    versionType: row.versionType,
                    version: row.version
                }
                this.submitWeb(params);
            },
            toPublishApp: function (index, row) {
                console.log("row:")
                console.log(row)
                if(util.isEmpty(row.webVersion) ){
                    row.webVersion={installPackageUrl: '', accessUrl: '', versionType: 1}
                }
                if(util.isEmpty(row.iosVersion) ){
                    row.iosVersion={installPackageUrl: '', accessUrl: '', versionType: 2}
                }
                if(util.isEmpty(row.androidVersion) ){
                    row.androidVersion={installPackageUrl: '', accessUrl: '', versionType: 3}
                }
                this.toPublishAppData.toPublishAppObj=row;
                this.toPublishAppData.toPublishAppObj.isSystemApp=this.toPublishAppData.toPublishAppObj.isSystemApp+""; // 兼容各种下拉选择框什么的，js的数字0 选择不上的bug
                this.toPublishAppData.toPublishAppObj.classification=this.toPublishAppData.toPublishAppObj.classification+"";
                this.toPublishAppData.toPublishAppObj.network=this.toPublishAppData.toPublishAppObj.network+"";

                this.publishAppSubPageVisible = true;
                this.publishAppPageVisible=true;
            },
            // 初始化app类型 start
            loadAppTypeObjlist() {
                var _this = this;
                console.log("初始化app类型 start:")
                getApplicationTypeList({pageSize: 999999}).then(function (result) {
                    console.log("初始化app类型 结果:")
                    console.log(result)
                    this.toPublishAppData.applicationTypeList=[];
                    this.toPublishAppData.applicationTypeList = result.data.list;
                }.bind(this)).catch(function (error) {
                    console.log(error);
                }.bind(this));

            },
            //初始化开发商列表
            getDeveloperList() {
                var _this = this;
                console.log("初始化开发商列表 start:")
                getSupplierList({pageSize: 999999}).then(function (result) {
                    console.log("初始化开发商列表 结果:")
                    console.log(result)
                    this.toPublishAppData.developerList=[];
                    result.data.list.forEach(function (element, index, array) {//当前元素的值、当前下标、数组本身
                        element.supplierCode=element.supplierCode+"";// 开发商编码在后台定义为智障数字类型，所以在这里转换进行处理
                        _this.toPublishAppData.developerList.push(element)
                    });
                    // this.toPublishAppData.developerList = result.data.list;
                }.bind(this)).catch(function (error) {
                    console.log(error);
                }.bind(this));
            },
            baseAddHiden(toPublishAppData){//点击保存或者是下一步时，进入选择市场界面
                console.log("基础信息提交完成，跳转中-------------------------------------------------------------------------------------")
                console.log(toPublishAppData)
                this.toPublishAppData = toPublishAppData;
                this.publishAppSubPageVisible = false;// 隐藏基础页面
                this.isShowSelectMarket = true;// 显示选择市场页面
            },
            baseAddShow(toPublishAppData){
                this.toPublishAppData = toPublishAppData;
                this.publishAppSubPageVisible = true;// 隐藏基础页面
                this.isShowSelectMarket = false;// 显示选择市场页面
            },
            closePublishAppPageDialog(){
                this.publishAppSubPageVisible = false;// 隐藏基础页面
                this.isShowSelectMarket = false;// 显示选择市场页面

            },
            deleteAllAppInfo(row){

                this.$confirm('确定删除应用 ？', "提示").then(yesOrNo => {
                    if(yesOrNo){
                        deleteAllAppInfo(row.appCode).then(function (result) {
                            console.log(result)
                            this.$message.info('app信息删除成功!!!   ');
                            this.getList();
                        }.bind(this)).catch(function (error) {
                            console.log("app信息,删除失败!!!  ");
                            console.log(error);
                            this.$message.error('app信息,删除失败!!!   ' + result.msg);
                        }.bind(this));
                    }else{
                        this.$message.info("删除已取消");
                    }
                }).catch(_ => {
                    this.$message.info("删除已取消");
                });
            },
            formatPublishFlag(row,column){
                if(row.ublishFlag == "1"){
                    return "已发布";
                }else{
                    return "审核中";
                }
            },
            toGetList: function () {
                this.getList();
            },
            //时间格式化
            formatCreateDate: function (row, column) {
                return row.createDate = (!row.createDate || row.createDate == '') ? '' : util.formatDate.format(new Date(row.createDate), 'yyyy-MM-dd hh:mm');
            },
            handleCurrentPageChange: function (pageNum) {// 翻页动作
                this.pageNum = pageNum;
                this.getList();// 翻页后刷新页面数据
            },
            handleClickDetail: function (index, row) {//版本信息弹框2
                this.appDetailInfo = row;
                console.log(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>")
                console.log(row)
                this.apptitle += row.appName;
                this.appDetailVisible = true;
            },
            handleClickModify: function(){//修改

            },
            underReview: function(){//审核中按钮
                //do something.
            },
            versionEditSecond: function (index, row) {//版本信息弹框2
                this.versionDialogSecond = true;
            },
            
        },
        computed: {
            placeholderText() {
                return this.$t("placeholderText");
            },
            placeholderDate() {
                return this.$t("placeholderDate");
            }
        },
        created() {
            this.lang = localStorage.lang || "zh-CN";
        },
        mounted() {
            this.getList();
            this.loadAppTypeObjlist();
            this.getDeveloperList();
            this.uploadUrl = util.uploadUrl(); //设置图片上传地址
            this.toPublishAppData.appClassificationList = util.getDictDatasByType("app_classification");// 接口所在区域 列表
        }
    };

    //标题栏居中显示
    setTimeout(()=>{
        const titleDiv = document.getElementsByClassName('is-leaf');
        const rowDiv = document.getElementsByClassName('el-table__row');
        const operationDiv = document.getElementsByClassName('el-table_4_column_25');
        for(let i = 0; i<titleDiv.length; i++){
            titleDiv[i].style.textAlign = 'center';
        }
        for(let j = 0; j<rowDiv.length; j++){
            rowDiv[j].style.textAlign = 'center';
        }
    },1500);
</script>

<style>
    .el-card__header{
        background: #DCDFE6;
    }
    #newPentagramId{
        float: right;
        width: 220px;
        height: 40px;
        /* background: #DCDFE6; */
        /* color: blue; */
        line-height: 50px;
    }
    .el-table_8_column_41,el-table_1_column_1{
        min-width: 40px;
    }
    .el-table thead{
         /* 标题栏底色 */
        background: #f3f7fc;
    }
    .has-gutter{
        /* 标题栏底色 */
        background: #f3f7fc;
    }
    .titleDetailLeft{
        text-align:left; 
        margin-left:30px;
    }
</style>
